﻿#region Copyright(C) 2012 NCS Pte. Ltd. All rights reserved.

// ==================================================================================================
// Copyright(C) 2012 NCS Pte. Ltd. All rights reserved.
//
// SYSTEM NAME	:   iConnect.Azure Application Framework
// COMPONENT ID :   NCS.IConnect.Azure.Diagnostics.AzureStorage.AzureStorageCloudBlobClient
// COMPONENT DESC:  	
//
// CREATED DATE/BY:  08 June 2012 / Lu Ya Ming
//
// REVISION HISTORY:	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

#endregion

using Microsoft.WindowsAzure.StorageClient;

namespace NCS.IConnect.Cloud.Core.AzureStorage
{
    /// <summary>
    /// The Azure storage cloud blob client.
    /// </summary>
    public class AzureStorageCloudBlobClient : ICloudBlobClient
    {
        private readonly CloudBlobClient blobClient;

        /// <summary>
        /// Initializes a new instance of the <see cref="AzureStorageCloudBlobClient"/> class.
        /// </summary>
        /// <param name="blobClient">The BLOB client.</param>
        public AzureStorageCloudBlobClient(CloudBlobClient blobClient)
        {
            this.blobClient = blobClient;
        }

        /// <summary>
        /// Gets or sets the retry policy.
        /// </summary>
        /// <value>
        /// The retry policy.
        /// </value>
        public RetryPolicy RetryPolicy
        {
            get { return this.blobClient.RetryPolicy; }
            set { this.blobClient.RetryPolicy = value; }
        }

        /// <summary>
        /// Gets the container reference.
        /// </summary>
        /// <param name="containerAddress">The container address.</param>
        /// <returns></returns>
        public ICloudBlobContainer GetContainerReference(string containerAddress)
        {
            return new AzureStorageCloudBlobContainer(this.blobClient.GetContainerReference(containerAddress));
        }
    }
}
